/**
 ******************************************************************************
 * @file    main.c
 * @author  Milandr Application Team
 * @version V0.2.0
 * @date    27/04/2026
 * @brief   Main program body.
 ******************************************************************************
 * THE PRESENT FIRMWARE IS FOR GUIDANCE ONLY. IT AIMS AT PROVIDING CUSTOMERS
 * WITH CODING INFORMATION REGARDING MILANDR'S PRODUCTS IN ORDER TO FACILITATE
 * THE USE AND SAVE TIME. MILANDR SHALL NOT BE HELD LIABLE FOR ANY
 * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES RESULTING
 * FROM THE CONTENT OF SUCH FIRMWARE AND/OR A USE MADE BY CUSTOMERS OF THE
 * CODING INFORMATION CONTAINED HEREIN IN THEIR PRODUCTS.
 */

/* Includes ------------------------------------------------------------------*/
#include "MDR12065_config.h"
#include "FreeRTOS.h"
#include "queue.h"
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>

/* Private definitions -------------------------------------------------------*/

/* Private functions prototypes ----------------------------------------------*/
void freertos_risc_v_trap_handler(void);
void freertos_risc_v_mtimer_interrupt_handler(void);
void CLIC_FreeRTOS_Init(void);

/* Private variables ---------------------------------------------------------*/

/* Private functions ---------------------------------------------------------*/

/**
 * @brief  Interrupt initialization function for FreeRTOS operation.
 * @param  None.
 * @return None.
 */
void CLIC_FreeRTOS_Init(void)
{
    IT_GlobalDisableIRQ(IT_PRIVILEGE_MODE_IRQ_M);

    /* FreeRTOS: override the trap handler.*/
    CLIC_SetTrapVector(CLIC_PRIVILEGE_MODE_IRQ_M, freertos_risc_v_trap_handler);
    /* FreeRTOS: override the machine timer interrupt handler.*/
    InterruptVectorTable[MTIP_IRQn] = freertos_risc_v_mtimer_interrupt_handler;

    IT_GlobalEnableIRQ(IT_PRIVILEGE_MODE_IRQ_M);
}

/**
 * @brief  Main program.
 * @param  None.
 * @return None.
 */
int main()
{
    CLIC_FreeRTOS_Init();

    while (1) { }
}

